const state = {
  word: new Array(),
  wordSelectModel: ''
}
const mutations = {
  SET_WORD: (state, data) => {
    try {
      for (let i = 0; i < state.word.length; i++) {
        if (state.word[i].id == data.id) {
            state.word.splice(i, 1)
        }
      }
    } catch (e) {
    }
    state.word.push(data)
  },
  SET_WORD_SELECT_MODEL: (state, data) => {
      state.wordSelectModel=data
  },
  CLEAN_WORD: (state) => {
    state.word = new Array()
    state.wordSelectModel=''
  },
  CLEAN_WORD_DATA: (state) => {
    state.word = new Array()
  }
}

const actions = {
  // 设置代理等级
  setWord({ commit }, data) {
    commit('SET_WORD', data)
  },
  // 设置代理选择模式
  setWordSelectModel({ commit }, data) {
    commit('SET_WORD_SELECT_MODEL', data)
  },
  // 清空代理-全部清空
  cleanWord({ commit }) {
    commit('CLEAN_WORD')
  },
  // 清空代理-选中数据
  cleanWordData({ commit }) {
    commit('CLEAN_WORD_DATA')
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

